home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
prolog
/
modprolg
/
mod-prol.lha
/
Prolog
/
Examples
/
utils1.mod
< prev
Wrap
Text File
|
1992-06-09
|
872b
|
30 lines
structure utils1 =
struct
% For each X do Y.
foreach(X,Y) :-
call(X),
do(Y),
fail.
foreach(_,_).
do(Y) :-
call(Y),!.
% Read in a sentence, terminated by a '.' and tag
% each word with Tag.
get_sentence(Wordlist,Tag) :-
get0(Char),
getrest(Char,Wordlist,Tag).
getrest(46,[],_) :- !.
getrest(32,Wordlist,Tag) :- !,
get_sentence(Wordlist,Tag).
getrest(Letter,[Word|Wordlist],Tag) :-
getletters(Letter,Letters,Nextchar),
name(Word,Letters,Tag),
getrest(Nextchar,Wordlist,Tag).
getletters(46,[],46) :- !.
getletters(32,[],32) :- !.
getletters(Let,[Let|Letters],Nextchar) :-
get0(Char),
getletters(Char,Letters,Nextchar).
end.